package regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegPhone {
    public static void main(String[] args) {
        String text = "联系我们: 010-12345678， 手机: 13800138000， 备用: 021-87654321";
//匹配手机号(11位)和座机号(区号-号码)
        String phoneRegex = "(1[3-9]\\d{9})|(\\d{3,4}-\\d{7,8})";
        Pattern pattern = Pattern.compile(phoneRegex);
        Matcher matcher = pattern.matcher(text);
        System.out.println("找到的电话号码: ");
        while (matcher.find()) {
            System.out.println(matcher.group());
        }
    }
}
